<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8" />
		<title>时间</title>
		<style>
			.a{
				width: 100px;
				height: 100px;
				border: 1px solid #000000;
				float: left;
				background: darkviolet;
				color: ghostwhite;
				line-height: 100px;
				text-align: center;
			}
		</style>
	</head>
	<body>
		<div>
			<h1>过年倒计时</h1>
			<div class="a"></div>
			<div class="a"></div>
			<div class="a"></div>
			<div class="a"></div>
			<div class="a"></div>
			
		</div>
		<script>
			var a=document.getElementsByClassName("a");
			var timego=new Date('2021-2-11 00:00:01');
			
			var shijian=setInterval(function(){
				var bendishijian=new Date();
				//console.log(bendishijian);
				var haomiaocha=timego - bendishijian;
				//console.log(bendihaomiao)
				
				
				
				
				var hao=(haomiaocha%1000);
				//console.log(hao)
				var sec=parseInt(haomiaocha/1000);
				//console.log(sec)
				var sescth=(sec%60);
				var min = parseInt(sec/60)%60;
				//console(min);
				var shi = parseInt(sec/3600)%24;
				var tian = parseInt(sec/86400)%365;
				
				a[0].innerHTML=tian + '天';
				a[1].innerHTML=shi + '小时';
				a[2].innerHTML=min+ '分';
				a[3].innerHTML=sescth+'秒';
				//a[4].innerHTML=hao+'毫秒';
				
				var haomiao="";
				if (hao<10){
					haomiao="00"+hao;
				}else if(hao>10 && hao<100){
					haomiao = "0"+hao;
				}else{
					haomiao=hao;
				}
				a[4].innerHTML=haomiao+'毫秒';
				
				
				
				
				
			},1)
			
			
			
			
			
			
			
			
			
		</script>
	</body>
</html>
